package cn.com.cifi.mars.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.com.cifi.mars.constant.IsDeleteEnum;
import cn.com.cifi.mars.entity.MdmProject;
import cn.com.cifi.mars.entity.MdmStage;
import cn.com.cifi.mars.entity.common.ProjectByStages;
import cn.com.cifi.mars.mapper.mars.ProjectMapper;
import cn.com.cifi.mars.mapper.mars.StageMapper;
import cn.com.cifi.mars.service.ProjectService;

/**
 * <p>
 * 项目表 服务实现类
 * </p>
 *
 * @author yyd
 * @since 2019-09-24
 */
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, MdmProject> implements ProjectService {

	@Autowired
	private ProjectMapper projectMapper;

	@Autowired
	private StageMapper stageMapper;

	@Override
	public MdmProject selectByProId(String projectId) {
		QueryWrapper<MdmProject> queryWrapper = new QueryWrapper<MdmProject>();
		queryWrapper.eq("project_id", projectId);
		return projectMapper.selectOne(queryWrapper);
	}

	@Override
	public MdmProject selectByProjectId(String projectId, int isDel) {
		return projectMapper.selectByProjectId(projectId,isDel);
	}

	@Override
	public void updateByProjectId(MdmProject project) {
		projectMapper.updateByProjectId(project);
	}

	@Override
	public void insertBatch(List<MdmProject> insertList) {
		projectMapper.insertBatch(insertList);
	}

	@Override
	public List<ProjectByStages> getParentData(String projectId) {
		return projectMapper.selectParentData(projectId);
	}

	@Override
	public List<MdmProject> selectAll() {
		QueryWrapper<MdmProject> queryWrapper = new QueryWrapper<MdmProject>();
		queryWrapper.eq("is_delete", IsDeleteEnum.NO.getKey());
		return projectMapper.selectList(queryWrapper);
	}

}
